import {
    resetRouter
} from "@/router";
import {
    getCommentList
} from "@/api/modules/musicScore"
import qs from "qs"
import {
    getUserName,
    setUserName
} from "@/utils/Storage";
const getDefaultState = () => {
    return {
        commentList: [],
        currentMusicScore: {},
        imgList: []
    };
};

const state = getDefaultState();

const mutations = {
    GETCURRENTCOMMENTLIST(state, commentList) {
        state.commentList = commentList
    },
    GETCURRENTARTICLE(state, musicScore) {
        state.currentMusicScore = musicScore
    },
    SETIMGLIST(state, img_url) {
        state.imgList.push(img_url);
    },
    SETMUSICSCORELIST(state, imgList) {
        state.imgList = imgList
    },
    SETFILEHASH(state, file_hash) {
        state.file_hash = file_hash
    }
};

const actions = {
    // 获取当前展开的评论列表
    async getCurrentCommentList({
        commit
    }, {
        musicScore,
        limit,
        page
    }) {
        console.log("datas", musicScore, limit, page)
        const res = await getCommentList(musicScore.id, limit, page)
        musicScore.limit = limit
        musicScore.page = page
        commit("GETCURRENTARTICLE", musicScore)
            // console.log("commentlist",res)
        if (res.status == 200) {
            commit("GETCURRENTCOMMENTLIST", res.data.payload)
            return "success"
        } else {
            return "error"
        }
    }
};

export default {
    namespaced: true,
    state,
    mutations,
    actions,
};